package day10;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class TimeAspect implements InvocationHandler {
    private Object target;
    public TimeAspect(Object target){
        this.target= target;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//        获取当前时间
        long t1 = System.currentTimeMillis();
        Object returnVal = method.invoke(target,args);
        long t2 = System.currentTimeMillis();
        System.out.println("耗时："+(t2-t1));
        return returnVal;
    }
}
